<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Sa-Token-SSO-Client端-测试页（前后端分离版-原生h5）</title>
</head>
<body>
<h2>Sa-Token SSO-Client 应用端（前后端分离版-原生h5）</h2>
<p>当前是否登录：<b class="is-login"></b></p>
<p>
  <a href="sso-login.html?back=http%3A%2F%2Flocalhost%3A63342%2Fsa-token-test%2Fh5-clientA%2Fh5%2Findex.html">登录</a>
  <a href="javascript:location.href=logoutUrl;">注销</a>
</p>
<script src="https://unpkg.zhimg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script type="text/javascript">

  // 后端接口地址
  var baseUrl = "http://localhost:9001";
  console.log(encodeURIComponent(location.href))
  var logoutUrl = baseUrl + '/sso/logout?satoken=' + localStorage.satoken + '&back=' + encodeURIComponent(location.href);
  // 查询当前会话是否登录
  $.ajax({
    url: baseUrl + '/sso/isLogin',
    type: "post",
    dataType: 'json',
    headers: {
      "X-Requested-With": "XMLHttpRequest",
      "satoken": localStorage.getItem("satoken")
    },
    success: function(res){
      $('.is-login').html(res.data + '');
    },
    error: function(xhr, type, errorThrown){
      return alert("异常：" + JSON.stringify(xhr));
    }
  });

</script>
</body>
</html>
